<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>分类页</title>
    <link rel="stylesheet" href="./css/style.css">
</head>

<body>
    <div class="fix-title">
        <div class="back">&lt;</div>
        <span>商品列表</span>
        <div class="text"><a href="search.html">搜索</a></div>
    </div>
    <div class="cate-list-fix">
        <ul>
            <li class="active"><a href="#">分类1</a></li>
            <li><a href="#">分类2</a></li>
            <li><a href="#">分类3</a></li>
            <li><a href="#">分类4</a></li>
            <li><a href="#">分类5</a></li>
        </ul>
    </div>
    <div class="good-list">
        <ul>
            
        </ul>
        <div class="empty">
            <span>空空如也...</span>
        </div>
        <p class="desc">数据正在加载中...</p>
        <p class="desc">我也是有底线的...</p>
    </div>
</body>
<script src="../jquery.js"></script>
<script>
    $(function () {
        $.ajax({
            method: 'get',
            url: 'http://124.223.14.236:3001/api/goods',
            success(res) {
                console.log(res);
                    let m = res.data.list.map(item => {
                        return `
                            <li>
                                <img src="${item.img}" alt="">
                                <h3>${item.title}</h3>
                                <p>
                                    <span>￥${item.price.toFixed(2)}</span>
                                    <span>+</span>
                                </p>
                            </li>
                `
                    }).join('')
                    $('.good-list ul').html(m)
            }
        })
    
    $('.cate-list-fix ul li').on('click',function(e){
        $(this).addClass('active').siblings('li').removeClass('active')
    })
    })
</script>

</html>